﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.IO;

namespace NLBS.Web.Modules
{
   public class WebSiteStatusModule : IHttpModule
    {
        #region IHttpModule Members

        public void Dispose()
        {
            //throw new NotImplementedException();
        }

        public void Init(HttpApplication context)
        {
            context.BeginRequest += new EventHandler(context_BeginRequest);
        }

        void context_BeginRequest(object sender, EventArgs e)
        {
            string currentPath = Path.GetDirectoryName(HttpContext.Current.Request.PhysicalPath);
            string lastPath = currentPath.Substring(currentPath.LastIndexOf("\\"), currentPath.Length - currentPath.LastIndexOf("\\"));
            if (BlogInfo.Instance().CurrentUser.GroupID != 1)
            {
                if (HttpContext.Current.Application["NlbsSiteClosed"] != null)
                {
                    HttpContext.Current.Response.Clear();
                    HttpContext.Current.Response.Write("网站已经关闭");
                    HttpContext.Current.Response.End();
                }
            }
        }

        #endregion
    }
}
